package de.uni.muenster.idw2.threads;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import android.graphics.drawable.Drawable;
import android.util.Log;
import de.uni.muenster.idw2.interfaces.AdapterLoaderInterface;

public class SilngelImgThread implements Runnable{
	
	private AdapterLoaderInterface gridLoaderThread;
	private final String s;
	private final int i;

	public SilngelImgThread(AdapterLoaderInterface gridLoaderThread, String s, int i){
		this.gridLoaderThread = gridLoaderThread;
		this.s = s;
		this.i = i;
		
	}

	@Override
	public void run() {
		try {
			Drawable img = Drawable.createFromStream((InputStream) new URL(s).getContent(), "draw");
			gridLoaderThread.addImage(img, i);
		
		} catch (MalformedURLException e) {
			Log.e("wichtig", e.toString());
		} catch (IOException e) {
			Log.e("wichtig", e.toString());
		} catch (OutOfMemoryError e) {
			Log.e("wichtig", e.toString());
		}catch (Throwable e) {
			Log.e("wichtig", e.toString());
		}
	}

}
